<template>
	<el-dialog width="800px" title="上征信" :visible.sync="dialogVisible" :close-on-click-modal="false">
		<el-form :model="form" :rules="rules" ref="ruleForm" label-width="100px">
			<el-form-item label="居住地邮编" label-width="200px">
				<el-input v-model="form.resiPc"></el-input>
			</el-form-item>
			<el-form-item label="身份证有效期开始日期" label-width="200px">
				<el-input v-model="form.ocrStart"></el-input>
			</el-form-item>
			<el-form-item label="身份证有效期结束日期(长期填2099-12-31)" label-width="200px">
				<el-input v-model="form.ocrEnd"></el-input>
			</el-form-item>
			<el-form-item label="身份证地址" label-width="200px">
				<el-input v-model="form.ocrAddress"></el-input>
			</el-form-item>
			<el-form-item label="身份证民族" label-width="200px">
				<el-input v-model="form.ocrNation"></el-input>
			</el-form-item>
			<el-form-item label="身份证发证机关" label-width="200px">
				<el-input v-model="form.ocrIssueOrg"></el-input>
			</el-form-item>
		</el-form>
		<div slot="footer" class="dialog-footer">
			<el-button size="small" @click="dialogVisible = false">取 消</el-button>
			<el-button size="small" type="primary" @click="submit">确 定</el-button>
		</div>
	</el-dialog>
</template>

<script>
	import {
		setCreditData2
	} from "@/api/order";
	export default {
		props:{
			orderId:{
				type: String,
				default: ''
			}
		},
		data() {
			return {
				form: {
					ocrStart: "",
					resiPc: '',
					ocrEnd:'',
					ocrIssueOrg:'',
					ocrNation:'',
					ocrAddress:'',
					orderId:''
				},
				rules: {
					resiPc: [{
						required: true,
						message: '居住地邮编',
						trigger: 'blur'
					}],
					ocrStart: [{
						required: true,
						message: '身份证有效期开始日期',
						trigger: 'blur'
					}],
					ocrEnd: [{
						required: true,
						message: '身份证有效期结束日期',
						trigger: 'blur'
					}],
					ocrAddress: [{
						required: true,
						message: '身份证地址',
						trigger: 'blur'
					}],
					ocrNation: [{
						required: true,
						message: '身份证民族',
						trigger: 'blur'
					}],
					ocrIssueOrg: [{
						required: true,
						message: '身份证发证机关',
						trigger: 'blur'
					}]
				},
				dialogVisible: false
			}
		},
		methods: {
			submit() {
				this.$refs['ruleForm'].validate((valid) => {
					if (valid) {
						this.form.orderId=this.orderId
						setCreditData2({
							...this.form
						}).then(res => {
							this.dialogVisible = false;
							this.$emit('getList', true);
						})
					} else {
						this.$message({
							message: "请检查表单错误",
							type: "error"
						});
						return false;
					}
				});
			}
		},
		watch: {
			dialogVisible(val) {
				// if (val) {
				// 	this.form.orderId = this.orderId;
				// 	this.form.remark = '';
				// } else {
				// 	this.$refs['ruleForm'].resetFields();
				// }
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>